import { isUrl } from '../utils/utils';

const menuData = [
  {
    name: '日常监控',
    icon: 'dashboard',
    path: 'dashboard',
    children: [
      {
        name: '概览',
        path: 'analysis',
      },
    ],
  },
  {
    name: '内容管理',
    icon: 'edit',
    path: 'content',
    children: [
      {
        name: '内容管理',
        path: 'content',
      },
      {
        name: '频道管理',
        path: 'channel',
      },
      {
        name: '内容标签管理',
        path: 'tag',
      },
      {
        name: '作者管理',
        path: 'author',
      },
      {
        name: '平板端推荐管理',
        path: 'padRecomm',
      },
      {
        name: '家长端推荐管理',
        path: 'parentRecomm',
      },
    ],
  },
  {
    name: '活动管理',
    icon: 'edit',
    path:'activity',
    children: [
      {
        name: '活动管理',
        path: 'activity',
      }]
  },
  {
    name: '会员管理',
    icon: 'user',
    path: 'member',
    children: [
      {
        name: '会员管理',
        path: 'member',
      },
      {
        name: '会员标签管理',
        path: 'tag',
      },
      {
        name: '优惠券管理',
        path: 'coupon',
      },
      {
        name: '会员付费管理',
        path: 'pay',
      },
      {
        name: '会员权益设置',
        path: 'setting',
      },


      // {
      //   name: '会员营销',
      //   path: 'marketing',
      // },
    ],
  },
  {
    name: '订单管理',
    icon: 'profile',
    path: 'order',
    children: [
      {
        name: '订单管理',
        path: 'order',
      },
    ],
  },
  {
    name: '加盟商管理',
    icon: 'shop',
    path: 'fran',
    children: [
      {
        name: '加盟商管理',
        path: 'fran',
      },
    ],
  },
  {
    name: '门店管理',
    icon: 'shop',
    path: 'store',
    children: [
      {
        name: '门店维护',
        path: 'store',
      },
    ],
  },
  {
    name: '积分商城管理',
    icon: 'gift',
    path: 'points',
    children: [
      {
        name: '运营位管理',
        path: 'position',
      },
      {
        name: '商品管理',
        path: 'goods',
      },
      {
        name: '商品类目管理',
        path: 'category',
      },
    ],
  },
];

function formatter(data, parentPath = '/', parentAuthority) {
  return data.map(item => {
    let { path } = item;
    if (!isUrl(path)) {
      path = parentPath + item.path;
    }
    const result = {
      ...item,
      path,
      authority: item.authority || parentAuthority,
    };
    if (item.children) {
      result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
    }
    return result;
  });
}

export const getMenuData = () => formatter(menuData);
